#!/bin/sh

set -e
set -u

PATH="/usr/local/bin:${PATH}"
KEXEC_CONF=/etc/default/kexec

KERNEL_IMAGE=$(tails-boot-to-kexec kernel $(tails-get-bootinfo kernel))
INITRD=$(tails-boot-to-kexec initrd $(tails-get-bootinfo initrd))

echo "KERNEL_IMAGE=\"${KERNEL_IMAGE}\""   >> "$KEXEC_CONF"
echo "INITRD=\"${INITRD}\""               >> "$KEXEC_CONF"

if grep -qw debug=wipemem /proc/cmdline; then
   echo 'APPEND="${APPEND} sdmemdebug=1"' >> "$KEXEC_CONF"
else
   echo 'APPEND="${APPEND} quiet"'        >> "$KEXEC_CONF"
fi
